package com.hejjon.core.constant;

import com.hejjon.core.bean.TableColumn;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class TableFieldConstants {

    public static final String FIELD_ID = "id";

    public static final String FIELD_PARENT_ID = "parent_id";

    public static final String FIELD_FEATURE_ID = "feature_id";

    public static final String FIELD_DELETE_FLAG = "delete_flag";

    public static final String FIELD_ROW_NUM = "row_num";

    public static final String FIELD_CREATE_TIME = "create_time";

    public static final String FIELD_UPDATE_TIME = "update_time";

    public static final String STR_JDBCTYPE = "VARCHAR";

    public static final String INT_JDBCTYPE = "INT";

    public static final String DATETIME_JDBCTYPE = "DATETIME";

    public static final Integer VARCHAR_DEFAULT_LENGTH = 32;

    public static final Integer INT_DEFAULT_LENGTH = 4;

    public static final Integer CHAR_DEFAULT_LENGTH = 1;

    public static final String DEFAULT_STR_FIELD_VALUE = "";

    public static final Integer DEFAULT_INT_FIELD_VALUE = 0;

    public static final String DEFAULT_DELETE_FLAG_VALUE = SysConstants.NOT_DELTE_CODE;      // 删除标记默认不删除

    public static final Date DEFAULT_CREATE_TIME_VALUE = null;

    public static final Date DEFAULT_UPDATE_TIME_VALUE = null;

    public static final String ID_COMMENT = "主键";

    public static final String PARENT_ID_COMMENT = "父节点ID";

    public static final String FEATURE_ID_COMMENT = "特征ID";

    public static final String DELETE_FLAG_COMMENT = "删除标记(1删除0未删除)";

    public static final String ROW_NUM_COMMENT = "行序号";

    public static final String CREATE_TIME_COMMENT = "新增时间";

    public static final String UPDATE_TIME_COMMENT = "更新时间";

    public static TableColumn ID_COLUMN = new TableColumn(FIELD_ID, STR_JDBCTYPE, VARCHAR_DEFAULT_LENGTH, true, ID_COMMENT, DEFAULT_STR_FIELD_VALUE, true);

    public static TableColumn PARENT_ID_COLUMN = new TableColumn(FIELD_PARENT_ID, STR_JDBCTYPE, VARCHAR_DEFAULT_LENGTH, true, PARENT_ID_COMMENT, DEFAULT_STR_FIELD_VALUE, false);

    public static TableColumn FEATURE_ID_COLUMN = new TableColumn(FIELD_FEATURE_ID, STR_JDBCTYPE, VARCHAR_DEFAULT_LENGTH, true, FEATURE_ID_COMMENT, DEFAULT_STR_FIELD_VALUE, false);

    public static TableColumn DELETE_FLAG_COLUMN = new TableColumn(FIELD_DELETE_FLAG, STR_JDBCTYPE, CHAR_DEFAULT_LENGTH, true, DELETE_FLAG_COMMENT, DEFAULT_DELETE_FLAG_VALUE, false);

    public static TableColumn ROW_NUM_COLUMN = new TableColumn(FIELD_ROW_NUM, INT_JDBCTYPE, INT_DEFAULT_LENGTH, false, ROW_NUM_COMMENT, DEFAULT_INT_FIELD_VALUE, false);

    public static TableColumn CREATE_TIME_COLUMN = new TableColumn(FIELD_CREATE_TIME, DATETIME_JDBCTYPE, null, false, CREATE_TIME_COMMENT, DEFAULT_CREATE_TIME_VALUE, false);

    public static TableColumn UPDATE_TIME_COLUMN = new TableColumn(FIELD_UPDATE_TIME, DATETIME_JDBCTYPE, null, false, UPDATE_TIME_COMMENT, DEFAULT_UPDATE_TIME_VALUE, false);

    /**
     * 默认字段列表
     */
    public static List<TableColumn> getDefaultColumnList() {
        List<TableColumn> columnList = new ArrayList<>();
        columnList.add(TableFieldConstants.ID_COLUMN);
        columnList.add(TableFieldConstants.PARENT_ID_COLUMN);
        columnList.add(TableFieldConstants.FEATURE_ID_COLUMN);
        columnList.add(TableFieldConstants.DELETE_FLAG_COLUMN);
        columnList.add(TableFieldConstants.ROW_NUM_COLUMN);
        columnList.add(TableFieldConstants.CREATE_TIME_COLUMN);
        columnList.add(TableFieldConstants.UPDATE_TIME_COLUMN);
        return columnList;
    }

}
